package com.lc.login.mvp.ui.activity;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.lc.baseres.base.BaseActivity;
import com.lc.baseres.dagger.component.AppComponent;
import com.lc.login.R;
import com.lc.login.di.component.DaggerLoginComponent;
import com.lc.login.di.module.LoginModule;
import com.lc.login.mvp.contract.LoginContract;
import com.lc.login.mvp.presenter.LoginPresenter;

@Route(path = "/login/home")
public class LoginActivity extends BaseActivity<LoginPresenter> implements LoginContract.View {
    private Button login_btn;
    private EditText login_name;
    private EditText login_password;

    @Override
    public void setupActivityComponent(AppComponent appComponent) {
        DaggerLoginComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .loginModule(new LoginModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int getContentView() {
        return R.layout.login_activity;
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        login_btn = findViewById(R.id.login_btn);
        login_name = findViewById(R.id.login_name);
        login_password = findViewById(R.id.login_password);
        login_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPresenter.checkLogin();
            }
        });
    }

    @Override
    public String getUserName() {
        return login_name.getText().toString();
    }

    @Override
    public String getPassword() {
        return login_password.getText().toString();
    }
}
